home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13518 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  39 lines

  1. Newsgroups: comp.lang.c
  2. Path: leeds.ac.uk!news
  3. From: csyamc@scs.leeds.ac.uk (A M Casey)
  4. Subject: accessing structures via pointers
  5. Message-ID: <1996Apr8.144012.25767@leeds.ac.uk>
  6. NNTP-Posting-Host: csgi33.leeds.ac.uk
  7. Organization: The University of Leeds, School of Computer Studies
  8. Date: Mon, 8 Apr 1996 15:40:12 +0100 (BST)
  9.  
  10. Hi I'm calling the function getgrent(), which resturns a structure
  11. as defined in grp.h, ie
  12.  
  13.  struct group {
  14.                  char    *gr_name;   /* the name of the group */
  15.                  char    *gr_passwd; /* the encrypted group password */
  16.                  gid_t   gr_gid;     /* the numerical group ID */
  17.                  char    **gr_mem;   /* vector of pointers to member names */
  18.           };
  19. the trouble is it returns a pointer to the structure:
  20.  
  21. struct group *getgrent(void);
  22.  
  23.  
  24. and I havent got a clue how to access it. I've lookied at the faq, but
  25. I'm still stuck.
  26.  
  27. I need something like
  28.  
  29. printf("the group name is %s\n",tempgroup.gr_name);
  30.  
  31. but that doesnt work because tempgroup is a pointer.
  32.  
  33. How do I do this?
  34.  
  35. Cheers
  36.  
  37. Andy
  38.  
  39.